<?php
namespace app\system\model;
use think\Model;

/**
 * 广告模型
 *
 * */

class ContentModel extends Model {
	
	//开启自动完成字段
//	protected $autoWriteTimestamp = true;
	//新增时候字段的名称
//	protected $createTime = 'time';
	//关闭更新字段
//	protected $updateTime = false;

	protected $table='__CONTENT__';

	/**
	 * 关联我的分类
	 */
	public function contentClass()
	{
		return $this->belongsTo('Contentclass','contentclass_id');
	}

    /**
     * @param array $where
     * @param bool $pageSize
     * @param string $order
     * @return false|\PDOStatement|string|\think\Collection|\think\Paginator
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     */
    public function selectContent(array $where=[], $pageSize=false, $order='id desc')
    {
        $this->where($where)->order($order);
        if ($pageSize) {
            $result = $this->paginate($pageSize);
        } else {
            $result = $this->select();
        }
        return $result;
    }

    /**
     * @param $field
     * @param bool $where
     * @return mixed
     */
    public function valueField($field, $where=false) {
        return $this->where($where)->value($field);
    }
}